package effect;

import card.CreatureCard;
import card.lands.Mountains;
import core.Core;
import core.MapUtil;
import effect.Effect.EffectType;



public class BuildMine extends Effect {
	
	public BuildMine(){
		name="Build Gold Mine";
		description="Builds a mine in a mountain to increase the gold production of this land by 1. Costs 3 gold and this units action.";
		imageName="cardIconBuildMine.png";
		effectTypes.add(EffectType.activatable);
		effectTypes.add(EffectType.goldModifier);
		targetType = TargetType.none;
		goldCost = 3;

	}
	@Override
	public void activate(){
		EffectUtil.getCard(this).getOwner().addGold(-3);
		if(EffectUtil.getCard(this) instanceof CreatureCard){
			CreatureCard temp;
			temp = (CreatureCard) EffectUtil.getCard(this);
			temp.setActionsLeft(0);
		}
		Effect newEffect = EffectGenerator.generateEffect("GoldMine");
		MapUtil.getTileOfCard(EffectUtil.getCard(this)).getLandCard().addEffect(newEffect);
	}
	
	@Override
	public boolean canActivate(){
		CreatureCard temp;
		temp = (CreatureCard) EffectUtil.getCard(this);
		if(temp.getOwner().getGold()>=3 &&
				temp.hasActionLeft() == true &&
				MapUtil.getTileOfCard(temp).getLandCard() instanceof Mountains){
			for(Effect e : MapUtil.getTileOfCard(temp).getLandCard().getEffects())
				if(e instanceof GoldMine)
					return false;
			return true;
		}
		else
			return false;
	}
	
	@Override
	public String getDescription(){
		return description;
	}
	
	@Override
	public String getImageName(){
		return imageName;
	}
}